#!/bin/bash

# ----------------------------------------------------------------------
# Filename:   75553-c.sh
# Version:    1.0
# Date:       2013/12/02
# Author:     yuanhui.shi
# Email:      yuanhui.shi@cs2c.com.cn
# Summary:    02系统基本功能-07开发环境-01语言支持-04C语言
# Notes:      C语言
# Copyright:  China Standard Software Co., Ltd.
# History：     
#             Version 1.0, 2013/12/02
#             -   The first one
# ----------------------------------------------------------------------

PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH

source ../../lib/Echo.sh

source ../../lib/XmlParse.sh


function CleanData ()
{
  rm -rf hello.c
  rm -rf hello
  EchoInfo "75553-c.sh执行完毕"
}

trap "CleanData" EXIT INT

#执行C文件
echo "#include <stdio.h>" >hello.c
echo "int main()" >>hello.c
echo "{" >>hello.c
echo 'printf ( "hello world!\n" );' >>hello.c
echo "return 0;" >>hello.c
echo "}" >>hello.c
cat hello.c
gcc -o hello hello.c
[ -n "`file hello | grep executable`" ] 
EchoResult "C文件编译成功"


[ "`./hello`" == "hello world!" ]
EchoResult "执行.c文件成功"

